package com.danci.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ResponseControllerAdvice {


    @ExceptionHandler(value = Exception.class)
    public Result exceptionHandler(Exception e) {
        log.error(String.format("Exception错误详情:%s",e.getMessage()));
        return Result.fail(e.getMessage());
    }
    @ExceptionHandler(value = RuntimeException.class)
    public Result exceptionRuntimeHandler(RuntimeException e) {
        log.error(String.format("RuntimeException错误详情:%s",e.getMessage()));
        return Result.fail(e.getMessage());
    }
}
